package com.project.server.operate;

import com.project.common.annotation.Log;
import com.project.common.core.controller.BaseController;
import com.project.common.core.domain.AjaxResult;
import com.project.common.core.page.TableDataInfo;
import com.project.common.enums.BusinessType;
import com.project.common.utils.poi.ExcelUtil;
import com.project.server.domain.operate.TOperateInvestment;
import com.project.server.service.operate.ITOperateInvestmentService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 运营管理招商引资Controller
 *
 * @author project
 * @date 2021-07-01
 */
@RestController
@RequestMapping("/server/investment")
public class TOperateInvestmentController extends BaseController {

    @Resource
    private ITOperateInvestmentService tOperateInvestmentService;

    /**
     * 查询运营管理招商引资列表
     */
    //@PreAuthorize("@ss.hasPermi('server:investment:list')")
    @GetMapping("/list")
    public TableDataInfo list(TOperateInvestment tOperateInvestment) {
        startPage();
        List<TOperateInvestment> list = tOperateInvestmentService.selectTOperateInvestmentList(tOperateInvestment);
        return getDataTable(list);
    }


    /**
     * 导出运营管理招商引资列表
     */
    @PreAuthorize("@ss.hasPermi('server:investment:export')")
    @Log(title = "运营管理招商引资", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TOperateInvestment tOperateInvestment) {
        List<TOperateInvestment> list = tOperateInvestmentService.selectTOperateInvestmentDelTags(tOperateInvestment);
        ExcelUtil<TOperateInvestment> util = new ExcelUtil<TOperateInvestment>(TOperateInvestment.class);
        return util.exportExcel(list, "招商引资列表");
    }

    /**
     * 获取运营管理招商引资详细信息
     */
   // @PreAuthorize("@ss.hasPermi('server:investment:query')")
    @GetMapping(value = "/{investmentId}")
    public AjaxResult getInfo(@PathVariable("investmentId") Long investmentId) {
        return AjaxResult.success(tOperateInvestmentService.selectTOperateInvestmentById(investmentId));
    }

    /**
     * 新增运营管理招商引资
     */
    @PreAuthorize("@ss.hasPermi('server:investment:add')")
    @Log(title = "运营管理招商引资", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody TOperateInvestment tOperateInvestment) {
        return toAjax(tOperateInvestmentService.insertTOperateInvestment(tOperateInvestment));
    }

    /**
     * 修改运营管理招商引资
     */
    @PreAuthorize("@ss.hasPermi('server:investment:edit')")
    @Log(title = "运营管理招商引资", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody TOperateInvestment tOperateInvestment) {
        return toAjax(tOperateInvestmentService.updateTOperateInvestment(tOperateInvestment));
    }

    /**
     * 删除运营管理招商引资
     */
    @PreAuthorize("@ss.hasPermi('server:investment:remove')")
    @Log(title = "运营管理招商引资", businessType = BusinessType.DELETE)
    @DeleteMapping("/{investmentIds}")
    public AjaxResult remove(@PathVariable Long[] investmentIds) {
        return toAjax(tOperateInvestmentService.deleteTOperateInvestmentByIds(investmentIds));
    }
}
